﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace EP2_LoginServer
{
    class Packages
    {
        public static MemoryStream ServerList()
        {

            int ChannelCount = 1;
            int ServerCount = Config.GameServerChannels;
            int LastLoggedInServer = 1;
            int LastLoggedInChannel = 1;
            byte RecommendedServer = 0;
            int ServerID = 1; // Katar = 1
            string ip = Config.GameServerIP;
            int port = Config.GameServerPort;

            MemoryStream td = new MemoryStream();
            td.AddByte(0x22);
            td.AddInt32(LastLoggedInServer);
            td.AddInt32(LastLoggedInChannel);
            td.AddInt32(ServerCount);
            td.AddInt32(1); 
            td.AddInt32(ServerID); 
            td.AddInt32(ChannelCount);
            td.AddByte(RecommendedServer);

            for (int a = 0; a <= 7; a++)
            {
                td.AddInt32(a + 1);
                td.AddInt32(2221);
                td.AddString(ip);
                td.AddByte(0x00);
                td.AddInt32(port + a);
            }

            return td;

        }

        public static byte[] LoginFail()
        {
            byte[] pack = { 0x01, 0x1F };
            return pack;
        }
 
    }
}
